package com.infosys.newSimpleInvertedIndex.dto;

import com.infosys.newSimpleInvertedIndex.helper.IdNumberHelper;
import com.infosys.newSimpleInvertedIndex.entities.Employee;

import java.util.List;

/**
 * name
 * employee id
 * government id
 * department
 * enroll date
 * age
 * relatives
 * resume
 */
public class EmployeeDTOO {
    private String id;
    private String name;
    private String employeeId;
    private String govId;
    private String department;
    private String enrollDate;

    private List<RelativeDTOO> relatives;
    private ResumeDTO resume;

    public EmployeeDTOO() {
    }

    public EmployeeDTOO(Employee employee){
        this.id = employee.getId();
        this.name = employee.getName();
        this.employeeId = employee.getId();
        this.govId = employee.getGovId();
        this.department = employee.getDepartment();
        this.enrollDate = employee.getEnrollDate().toString();

        this.relatives = null;
        this.resume = null;
        // resume and relatives are not set here
    }

    public EmployeeDTOO(String id, String name, String employeeId, String govId, String department, String enrollDate, int age, List<RelativeDTOO> relatives, ResumeDTO resume) {
        this.id = id;
        this.name = name;
        this.employeeId = employeeId;
        this.govId = govId;
        this.department = department;
        this.enrollDate = enrollDate;
        this.relatives = relatives;
        this.resume = resume;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }

    public String getGovId() {
        return govId;
    }

    public void setGovId(String govId) {
        this.govId = govId;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getEnrollDate() {
        return enrollDate;
    }

    public void setEnrollDate(String enrollDate) {
        this.enrollDate = enrollDate;
    }

    public List<RelativeDTOO> getRelatives() {
        return relatives;
    }

    public void setRelatives(List<RelativeDTOO> relatives) {
        this.relatives = relatives;
    }

    public ResumeDTO getResume() {
        return resume;
    }

    public void setResume(ResumeDTO resume) {
        this.resume = resume;
    }

    public String toString(){
        String str = "EmployeeDTOO{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", employeeId='" + employeeId + '\'' +
                ", govId='" + govId + '\'' +
                ", department='" + department + '\'' +
                ", enrollDate='" + enrollDate + '\'' +
                ", age=" + new IdNumberHelper().getAge(govId) +
                ", relatives=";
        if (relatives != null){
            for (RelativeDTOO relativeDTOO : relatives) {
                str += relativeDTOO.toString();
            }
        }
        str += ", resume=";
        if (resume != null){
            str += resume.toString();
        }
        return str + '}';
    }
}
